package com.zhan.utils.log.service.impl;

import cn.com.chinatelecom.callcenter.utils.Constants;
import cn.com.chinatelecom.callcenter.utils.log.service.MessageService;
import cn.com.chinatelecom.callcenter.utils.model.SysMessageDto;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;

import java.util.Date;

/**
 * @author baishangbing
 * @date 2019/12/19 10:03
 */
@Slf4j
public class MessageServiceImpl implements MessageService {
    private RedissonClient redissonClient;

    public MessageServiceImpl(RedissonClient redissonClient) {
        this.redissonClient = redissonClient;
    }

    @Override
    public void sendMessage(SysMessageDto sysMessageDto) {
        log.debug(JSONObject.toJSONString(sysMessageDto));
        sysMessageDto.setHappenTime(new Date());
        redissonClient.getQueue(Constants.QueueName.MESSAGE).add(sysMessageDto);
    }
}
